<?php
    header('Access-Control-Allow-Origin:*');//解决跨域
    header("Access-Control-Allow-Method:POST,GET");//允许发get和post请求
    include('conn.php');//加载外部数据库连接文件
    $usr = '%'.$_GET['username'].'%';
    //$usr = 'Howard Kennedy';
    //$sql = "select * from coach where coachName = '{$usr}'";//执行查询
    $sql = "select * from coach where coachName like '{$usr}'";//执行查询

    $result = mysqli_query($conn,$sql);
    while($row = mysqli_fetch_row($result)){
        $list[]=$row;
    }
    print_r(json_encode($list,JSON_UNESCAPED_UNICODE));//JSON_UNESCAPED_UNICODE:解决文字乱码问题
    //print_r(json_encode($list));//将结果发向前端（相当于创建了一个接口）print_r/print/echo
    //mysqli_query($conn , "set names utf8");